home *** CD-ROM | disk | FTP | other *** search
- //******************************************************************'
- //* *'
- //* TurboCAD for Windows *'
- //* Copyright (c) 1993 - 2004 *'
- //* International Microcomputer Software, Inc. *'
- //* (IMSI) *'
- //* All rights reserved. *'
- //* *'
- //******************************************************************'
- #include "StdAfx.h"
- #include "TcEngine.h"
- //class CTCEngine
- //{
- const IID IID_IApplication = {0x6A481101,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
-
- void TcGeometryVC_Net::TcEngine::CreategxApp(void)
- {
- if (m_gxApp == NULL)
- {
- HRESULT hRes = E_FAIL;
- CLSID lpclsid;
- IDispatch *pDisp = NULL;
- CString s("IMSIGX.Application");
- hRes = CLSIDFromProgID (s.AllocSysString (),&lpclsid);
- m_gxApp = new XApplicationClass;
- }
-
-
- }
-
- void TcGeometryVC_Net::TcEngine::CreategxDrawing(void)
- {
- System::Object* missing = NULL;
-
- try
- {
- if (m_gxApp == NULL)
- {
- CreategxApp();
- }
- if (m_gxDrawing != NULL)
- {
- MessageBox(NULL,"Drawing is already created !", NULL, MB_OK);
- }
- else
- {
- m_gxDrawing = m_gxApp->Drawings->Add(&missing);
- }
- }
-
- catch(System::Exception* exc)
- {
- }
- }
- void TcGeometryVC_Net::TcEngine::CreategxView(int hWnd)
- {
- Object* missing = NULL;
- Object* h;
- COleVariant var;
- try
- {
-
- //h = hWnd;
- if (this->m_gxDrawing != NULL)
- {
- h = __box(hWnd);
- this->m_gxView = this->m_gxDrawing->Views->Add(&h, &missing);
- // this->m_gxView = this->m_gxDrawing->Views->Add(__box(&hWnd), &missing);
- //this->m_gxView->HWND = hWnd;
- this->m_gxView->Update = false;
- this->m_gxView->MappingMode = 1;
- this->m_gxView->FixedAspectRatio = true;
- }
- }
-
- catch(System::Exception* exc)
- {
- //Console.WriteLine("{0} Caught exception .", exc);
- }
-
- }
- void TcGeometryVC_Net::TcEngine::Zoom(double dZoomFactor)
- {
- if (dZoomFactor != 0)
- {
- try
- {
- this->m_gxView->Camera->Zoom (dZoomFactor);
- }
- catch (...) // in case of paper space (not possible to get camera object in paperSpace) or unexpected error in model space
- {
- double xC = 0; double yC = 0;
- double w = 0; double h = 0;
-
- //On Error GoTo Err
- w = this->m_gxView->ViewWidth;
- h = this->m_gxView->ViewHeight;
-
- xC = this->m_gxView->ViewLeft + w / 2;
- yC = this->m_gxView->ViewTop - h / 2;
- w = w * dZoomFactor;
- h = h * dZoomFactor;
- this->m_gxView->Update = false;
-
- this->m_gxView->ViewLeft = xC - w / 2;
- this->m_gxView->ViewTop = yC + h / 2;
- this->m_gxView->ViewWidth = w;
- this->m_gxView->ViewHeight = h;
- }
- }
- else
- {
- this->m_gxView->ZoomToExtents ();
- }
- }
-
- IGraphic* TcGeometryVC_Net::TcEngine::SelectGraphic(double xScreen, double yScreen)
- {
- double xView, yView;
- System::Object* missing = NULL;
- System::Object* varVal;
- BOOL bRes = TRUE;
- System::Object* varTrue;
- bool varTmp __gc[] = new bool __gc[1];
- varTmp[0] = TRUE;
- varTrue = varTmp;
- PickResult* gxPickResult;
- PickEntry* gxPickEntry;
- IGraphic* gxvarGraphic = NULL;
-
- this->m_gxView->ScreenToView (xScreen, yScreen, &xView, &yView);
- //gxPickResult = this->m_gxView->PickPoint (xView, yView,&missing,&missing, &missing, &missing,&missing, &missing,&missing);
- gxPickResult = this->m_gxView->PickPoint(xView, yView, &varTrue ,&varTrue, &varTrue, &varTrue,&varTrue, &varTrue,&varTrue);
- if (gxPickResult->Count != 0 )
- {
-
- varVal = 0;
- gxPickEntry = gxPickResult->get_Item (&varVal);
- gxvarGraphic = gxPickEntry->Graphic;
- }
- else
- {
- this->m_gxDrawing->Graphics->Unselect ();
- }
- return gxvarGraphic;
- }
- }
- IGraphic* TcGeometryVC_Net::TcEngine::AddCircleCenterAndPoint(double x1Screen, double y1Screen, double x2Screen, double y2Screen)
- {
- double x1View, y1View, x2View, y2View, zView;
- double x1World, y1World, x2World, y2World;
- zView = 0;
- IGraphic* grRet = NULL;
-
- this->m_gxView->ScreenToView (x1Screen, y1Screen, &x1View, &y1View);
- this->m_gxView->ScreenToView (x2Screen, y2Screen, &x2View, &y2View);
- this->m_gxView->ViewToWorld (x1View, y1View,zView, &x1World, &y1World, &zView);
- this->m_gxView->ViewToWorld (x2View, y2View, zView, &x2World, &y2World, &zView);
-
- grRet = this->m_gxDrawing->Graphics->AddCircleCenterAndPoint (x1World, y1World, 0, x2World, y2World, 0);
- return grRet;
- }
- IGraphic* TcGeometryVC_Net::TcEngine::AddLineSingle(double x1Screen, double y1Screen, double x2Screen, double y2Screen)
- {
- double x1View, y1View, x2View, y2View, zView;
- double x1World, y1World, x2World, y2World;
- zView = 0;
- IGraphic* grRet = NULL;
-
- this->m_gxView->ScreenToView (x1Screen, y1Screen, &x1View, &y1View);
- this->m_gxView->ScreenToView (x2Screen, y2Screen, &x2View, &y2View);
- this->m_gxView->ViewToWorld (x1View, y1View,zView, &x1World, &y1World, &zView);
- this->m_gxView->ViewToWorld (x2View, y2View, zView, &x2World, &y2World, &zView);
-
- grRet = this->m_gxDrawing->Graphics->AddLineSingle (x1World,y1World,0,x2World,y2World,0);
- return grRet;
- }
-